
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="login_url" content="{$login}">
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

    <title>登录我的文档</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css">

    <!-- Custom styles for this template -->
    <link href="{:C("WWW")}static/css/signin.css" rel="stylesheet">

  </head>

  <body>

    <div class="container">

      <div class="form-signin" role="form">
        <div class="alert " role="alert" id="message_box"></div>
        <h2 class="form-signin-heading">请登录</h2>
        <input type="username" id="username" class="form-control" placeholder="用户名" required autofocus>
        <input type="password" id="password" class="form-control" placeholder="密码" required>
        <label class="checkbox">
          <input type="checkbox" value="remember-me"> 记住我
        </label>
        <button class="btn btn-lg btn-primary btn-block">登录</button>
      </div>

    </div>
    <script>
    $(document).ready(function(e) {

      $("button").click(function (e) {
        var username = $("#username").val();
        var password = $("#password").val();
        var login_url = $("meta[name='login_url']").attr('content');

        $.ajax({
          type: "POST",
          url: login_url,
          data: {'username':username,'password':password},
          success: function(msg){
            if (msg.result) {
              $("#message_box").removeClass("alert-danger");
              $("#message_box").addClass("alert-success");
              $("#message_box").html(msg.msg);
              window.location = msg.redirect_url;
            } else{
              $("#message_box").removeClass("alert-success");
              $("#message_box").addClass("alert-danger");
              $("#message_box").html(msg.msg);
              
            };
          }
        });

      });
      
    });
    </script>
  </body>
</html>
